X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/blobdiff_plain/f8aec187ea7dc410a32996406109f290f3199ffa..b587e9d8e0cc5eb1edf972fd3b644704441e5289:/Super%20Polarity/SuperPolarity.cs diff --git a/Super Polarity/SuperPolarity.cs b/Super Polarity/SuperPolarity.cs index e5f565b..8125f8c 100644 --- a/Super Polarity/SuperPolarity.cs +++ b/Super Polarity/SuperPolarity.cs @@ -7,6 +7,8 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; using Microsoft.Xna.Framework.GamerServices; +using Microsoft.Xna.Framework.Media; +using Microsoft.Xna.Framework.Audio; using SuperPolarity; #endregion @@ -17,16 +19,35 @@ namespace SuperPolarity /// public class SuperPolarity : Game { - public static GraphicsDeviceManager graphics; + public GraphicsDeviceManager graphics; SpriteBatch spriteBatch; + public static int OutlierBounds; + + public Player Player; + + Screen EntryScreen; + + protected Song TitleSong; + protected Song GameSong; + protected SoundEffect GameOverSound; + public SuperPolarity() : base() { - SuperPolarity.graphics = new GraphicsDeviceManager(this); - SuperPolarity.graphics.PreferMultiSampling = true; + graphics = new GraphicsDeviceManager(this); + graphics.PreferMultiSampling = true; + graphics.PreferredBackBufferWidth = 1280; + graphics.PreferredBackBufferHeight = 720; + graphics.ToggleFullScreen(); + Content.RootDirectory = "Content"; - ActorFactory.SetContentManager(Content); + ActorFactory.SetGame(this); + ParticleEffectFactory.SetGame(this); + ActorManager.SetGame(this); + ScreenManager.SetGame(this); + + EntryScreen = (Screen)new TitleScreen(this); } /// @@ -38,6 +59,19 @@ namespace SuperPolarity protected override void Initialize() { base.Initialize(); + + InputController.RegisterEventForKey("fullScreenToggle", Keys.F11); + InputController.Bind("fullScreenToggle", HandleFullScreenToggle); + + EntryScreen.Initialize(); + + OutlierBounds = 100; + } + + protected void HandleFullScreenToggle(float value) + { + graphics.ToggleFullScreen(); + graphics.ApplyChanges(); } /// @@ -46,12 +80,17 @@ namespace SuperPolarity /// protected override void LoadContent() { + + MediaPlayer.IsRepeating = true; + GameSong = Content.Load("Sound\\polaritytheme.wav"); + GameOverSound = Content.Load("Sound\\gameover"); + // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); - Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2); + ScreenManager.Push(EntryScreen); - ActorFactory.CreateMainShip(playerPosition); + Player = new Player(this); } /// @@ -73,10 +112,9 @@ namespace SuperPolarity if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); - // TODO: Add your update logic here + ScreenManager.Update(gameTime); - InputController.UpdateInput(); - ActorManager.Update(gameTime); + Player.Update(); base.Update(gameTime); } @@ -91,11 +129,27 @@ namespace SuperPolarity spriteBatch.Begin(); - ActorManager.Draw(spriteBatch); + ScreenManager.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); } + + public void PlaySong(string songName) + { + // temp stuff before media manager is in + if (songName == "game") + { + MediaPlayer.Play(GameSong); + } + } + + public void GameOver() + { + MediaPlayer.Stop(); + GameOverSound.Play(); + ScreenManager.Pop(); + } } }